
<meta charset="utf-8">
<style>
    #mask {
        background-color: #000;
        position: fixed;
        z-index: 300;
        top: 0;
        left: 0;
        overflow-x: hidden;
        overflow-y: auto;
        width: 100%;
        height: 100%;
        opacity: .5;
        -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50);
        filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50);
    }

    #popup .error {
        color: red !important;
        font-size: 12px;
    }

    .text-gray {
        color: rgb(121, 124, 127);
    }

    .back-svg .left {
        position: absolute;
        width: 100%;
        height: 100%;

        z-index: -10;
    }

    .back-svg .right {
        position: absolute;
        width: 100%;
        height: 100%;

        z-index: -10;
    }

    #popup .left-up .left {
        z-index: -5;
    }

    #popup .right-up .right {
        z-index: -5;
    }

    #popup .left-up ~ .back-svg-tab .left a:before,
    #popup .right-up ~ .back-svg-tab .right a:before {
        content: url("");
        display: inline-block;
        width: 160px;
        height: 63px;
        vertical-align: middle;
    }

    #popup .left-up ~ .back-svg-tab .left a:before {
        margin-left: -26px;
    }

    #popup .right-up ~ .back-svg-tab .right a:before {
        margin-left: 22px;
    }

    #popup .right-up ~ .back-svg-tab .left a,
    #popup .left-up ~ .back-svg-tab .right a {
        color: #545454;
    }

    #popup .right-up ~ .back-svg-tab .left a:hover,
    #popup .left-up ~ .back-svg-tab .right a:hover {
        color: #16d0d8;
    }

    .back-svg ~ .back-svg-tab .left li a,
    .back-svg ~ .back-svg-tab .right li a {
        display: inline-block;
        width: 300px;
        height: 66px;
        line-height: 66px;
        text-align: center;
        color: #16d0d8;
        font-size: 24px;
    }

    .back-svg ~ .back-svg-tab .right li a {
        float: right;
    }

    .back-svg-tab ~ .log-reg-box {
        padding: 60px 60px 49px;
        margin-top: 30px;
    }

    #popup .btn {
        padding: 0 33px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        -ms-border-radius: 4px;
        -o-border-radius: 4px;
        border-radius: 4px;
        margin: 0 6px;
        -webkit-transition: all .5s;
        -o-transition: all .5s;
        transition: all .5s;
        font-size: 16px;
        white-space: nowrap;
        box-sizing: border-box;
    }

    #popup {
        display: none;
    }

    #popup p {
        font-size: 16px;
    }

    #popup th {
        width: 125px;
    }

    #popup td {
        width: 300px;
        text-align: left
    }

    #popup div input[type='text'],div input[type='password'] {
        padding: 0 8px;
        height: 36px;
        font-size: 14px;
        line-height: 36px;
        box-sizing: border-box;
        width: 300px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        -ms-border-radius: 4px;
        -o-border-radius: 4px;
        border-radius: 4px;
    }

    input[type='text']:focus, #popup textarea, #popup select, input[type='password']:focus {
        border: 1px solid #14d0d9;
        -webkit-box-shadow: 1px 2px 5px #14d0d9, -1px -2px 5px #14d0d9;
        -moz-box-shadow: 1px 2px 5px #14d0d9, -1px -2px 5px #14d0d9;
        box-shadow: 0 0 5px 0 #14d0d9;
    }

    #popup input.verify-code {
        width: 120px;
    }

    #popup .pop-content {

        overflow-x: hidden;

        overflow-y: scroll;
    }

    #popup .wrap-box {
        position: fixed;
        display: block;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        box-sizing: border-box;
        width: 600px;
        height: 413px;
        margin: auto;
        z-index: 300;
        font-size: 16px;
    }

    #popup th {
        text-align: right;
        padding-right: 10px;
        line-height: 22px;
        font-size: 22px;
    }

    #popup tr {
        height: 16px;
        line-height: 16px;
    }

    #popup td {
        padding: 10px 0;
        line-height: 16px;
    }

    .verify-img {
        width: 132px;
        height: 32px;
        vertical-align: middle;
    }

    #popup table {
        margin-bottom: 20px;
    }

    .third img {
        width: 20px;
        height: 20px;
        vertical-align: -3px;
    }

    #popup p {
        font-size: 16px;
    }

    #popup .more, .more:hover {
        color: #16D0D8;
        text-decoration: underline;
    }

    .err-info {
        color: red;
    }

    .err-info h3 {
        font-weight: 400;
    }

    .let-me-login, .forget-password {
        color: rgb(121, 124, 127);
        float: right;
    }

    .let-me-login:hover, .forget-password:hover {
        color: #16D0D8;
        text-decoration: underline;
    }

    #popup .btn-primary, #popup .btn-primary:hover {
        display: inline-block;
        color: #ffffff;
        width: 245px;
        /* padding: 20px; */
        background-color: #16D0D8;
        -webkit-transition: all .3s;
        -moz-transition: all .3s;
        -ms-transition: all .3s;
        -o-transition: all .3s;
        transition: all .3s;
    }

    #popup .btn-primary:active {
        padding: 3px 6px 2px 8px;
        border: 2px inset;
        cursor: pointer;
        text-align: center;
        text-decoration: none;
        color: #ffffff;
    }

    #popup .callback-box .btn-primary, #popup .callback-box .btn-primary:hover {
        width: 140px;
    }

    .step-2 p, .step-3 p {
        text-align: center;
        margin: 10px 0;
    }

    .step-2 .let-me-login, .step-3 .let-me-login {
        float: none;
        position: relative;
        left: -68px;
    }

    .info {
        color: #16d0d8;

    }

    .tryAgain, .tryAgain:hover {
        display: inline-block;
        padding: 10px 13px;
        color: #ffffff;
        background-color: #16d0d8;
        margin-left: 10px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
    }

    .step-3 .email {
        color: #16d0d8;
        text-decoration: underline;
    }

    #popup .callback-box table {
        margin: 0 auto;
    }

    #popup .callback-box th {
        width: 135px;
    }

    #popup .wrap-box > .callback-box {
        padding: 60px 49px 120px;
        margin-top: 60px;
    }

    #popup tr .pd5 {
        padding: 5px 0;
    }
</style>
<div id="popup">
    <div id="mask">
    </div>


    <div class="pop-content">
        <div class="wrap-box">
            <div class="back-svg left-up">
                <div class="left">
                    <img src="">
                </div>
                <div class="right">
                    <img src="">
                </div>
            </div>
            <div class="back-svg-tab">
                <div class="log-reg-box hide">
                    <ul class="left fl">
                        <li class="step-0 hide">
                            <a href="javascript:void(0);"> 个人登录</a>
                        </li>
                        <li class="step-1 hide">
                            <a href="javascript:void(0);"> 个人注册</a>
                        </li>
                        <li class="step-2 hide">
                            <a href="javascript:void(0);"> 手机绑定</a>
                        </li>
                        <li class="step-3 hide">
                            <a href="javascript:void(0);"> 手机绑定</a>
                        </li>
                    </ul>
                    <ul class="right fl">
                        <li class="step-0 hide">
                            <a href="javascript:void(0);">商家登录</a>
                        </li>
                        <li class="step-1 hide">
                            <a href="javascript:void(0);">商家注册</a>
                        </li>
                        <li class="step-2 hide">
                            <a href="javascript:void(0);">邮箱绑定</a>
                        </li>
                        <li class="step-3 hide">
                            <a href="javascript:void(0);">邮箱绑定</a>
                        </li>
                    </ul>
                </div>
                <div class="callback-box hide">
                    <ul class="left fl">
                        <li class="callback-content hide">
                            <a href="javascript:void(0);"> 意见反馈</a>
                        </li>
                        <li class="report-content hide">
                            <a href="javascript:void(0);"> 举报</a>
                        </li>

                    </ul>
                    <ul class="right fl">

                    </ul>
                </div>
            </div>
            <div class="log-reg-box hide">
                <ul>
                    <li class="step-0 hide">

                        <table>
                            <tbody>
                            <tr>
                                <th>账号:</th>
                                <td><input type="text" name="username" placeholder="输入11位手机号码或邮箱账号" id="l-username">
                                </td>
                            </tr>
                            <tr>
                                <th>密码:</th>
                                <td><input type="password" name="password" placeholder="输入密码(6-18位数字或字母)"
                                           id="l-password">
                                </td>
                            </tr>
                            <tr class="l-err-info hide">
                                <th></th>
                                <td class="pd5"><b class="error">密码错误! -- $('.err-info').hide()</b></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td class="pd5">
                                    <p>
                                        <a href="javascript:void(0);" class="more">没有账号|注册</a>
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <p class="text-gray third" >第三方登录:
                                        <a href="https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id=101308377&redirect_uri=http%3A%2F%2Fwww.hiyouther.com/html/mod/qqLink.html&scope=get_user_info"  class="js-qq">
                                            <img src="">
                                        </a>
                                        <a href="javascript:void(0);" class="js-weixin hide">
                                            <img src="">
                                        </a>
                                        <a href="javascript:void(0);" class="js-weibo hide">
                                            <img src="">
                                        </a>
                                        <a href="javascript:void(0);" class="forget-password">忘记密码</a></p>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">登录</a></p>
                    </li>
                    <li class="step-1 hide">
                        <p class="text-theme" style="text-align: center;">建议店长使用手机注册,以便收到义工报名消息.</p>
                        <table>
                            <colgroup>
                                <col style="width: 100px;">
                                <col style="width: 300px;">
                            </colgroup>
                            <tbody>
                            <tr>
                                <th>用户名:</th>
                                <td><input type="text" name="username" placeholder="请输入11位手机号码或邮箱账号" id="r-username">
                                </td>
                            </tr>
                            <tr>
                                <th>密码:</th>
                                <td><input type="password" id="r-password"></td>
                            </tr>
                            <tr>
                                <th>确认密码:</th>
                                <td><input type="password" id="r-password-2"></td>
                            </tr>
                            <tr class="r-err-info hide">
                                <th></th>
                                <td class="pd5"><b class="error">密码错误! -- $('.err-info').hide()</b></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td class="pd5">
                                    <p>
                                        <input type="checkbox" id="r-agree">同意《用户服务协议》<a
                                            href="javascript:void(0);" class="more">点击查看详情</a>
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td class="pd5"><p class="text-gray third">第三方注册:
                                    <a href="https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id=101308377&redirect_uri=http%3A%2F%2Fwww.hiyouther.com/html/mod/qqLink.html&scope=get_user_info"   class="js-qq"><img
                                            src=""></a>
                                    <a href="javascript:void(0);" class="js-weixin hide"><img
                                            src=""></a>
                                    <a href="javascript:void(0);" class="js-weibo hide"><img
                                            src=""></a>
                                    <a href="javascript:void(0);" class="let-me-login">已有账号|登录</a></p>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">获取验证信息</a></p>
                    </li>
                    <li class="step-2 hide">
                        <p class="info">请求已发送!</p>

                        <table>
                            <tr>
                                <th>验证码:
                                </th>
                                <td>
                                    <input type="text" class="verify-code" id="r-verify-check"><a
                                        href="javascript:void (0);"
                                        class="tryAgain">60秒后重新获取</a>
                                </td>
                            </tr>
                            <tr class="err-info hide">
                                <th></th>
                                <td><b class="error">密码错误! -- $('.err-info').hide()</b></td>
                            </tr>
                        </table>
                        <p><a href="javascript:void(0);" class="let-me-login">已有账号|登录</a></p>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">下一步</a></p>
                    </li>
                    <li class="step-3 hide">
                        <p><input type="checkbox" checked="checked" readonly>已发送 <a href="javascript:void(0);"
                                                                                    class="email"
                                                                                    id="email-link" target="_blank">abc@abc.com</a>
                        </p>
                        <p>进入邮箱点击链接完成验证<br>
                            <span class="js-five-count">5</span>s 后自动关闭本弹窗 </p>
                        <p><a href="javascript:void(0);" class="let-me-login">已有账号|登录</a></p>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">关闭窗口</a></p>
                    </li>
                </ul>
            </div>
            <div class="callback-box hide">
                <ul>
                    <li class="callback-content hide">
                        <table>
                            <tbody>

                            <tr>
                                <th>名称:</th>
                                <td><input type="text" name="name" placeholder="输入相关名称"></td>
                            </tr>
                            <tr>
                                <th>反馈内容:</th>
                                <td>
                                    <textarea name="report" id="popup-callback" cols="40" rows="10" maxlength="200"
                                              placeholder="输入意见反馈内容(200字以内)"></textarea>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">提交</a></p>
                    </li>
                    <li class="report-content hide">
                        <table>

                            <tbody>

                            <tr>
                                <th>请输入举报对象:</th>
                                <td><input type="text" name="name" maxlength="200" placeholder="输入相关名称(200字以内)"></td>
                            </tr>
                            <tr>
                                <th>举报内容:</th>
                                <td><textarea name="report" id="popup-report" cols="40" rows="10" maxlength="200"
                                              placeholder="输入举报内容(200字以内)"></textarea>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="btn"><a href="javascript:void(0);" class="btn btn-primary">提交</a></p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<script>
    "use strict";
    require(['jquery', 'lib/common', 'business/report', 'business/router', 'business/jalert'], function ($, common, report, router, jalert) {
        var _public = {}
        var _private = {};

        _private.login = function (params, done, error,poppane) {
            common.send('login', params).done(function (result) {

                if (result && result.code == 1) {
                    done(result)
                } else if (result.code == -2) {
                    jalert.alert(result.info,"确定");
                    common.send("EmailVer",{option:"resend",emailname:params.account}).done(function(result){
                            poppane.close().reset();
                    });
                } else {
                    error(result.info);
                }
            }).error(function () {
                error("出了一些错误:" + result.info);
            })
        };

        _private.register = function (params, done, error) {
            common.send('register', params).done(function (result) {
                if (result && result.code == 1) {
                    done(result);
                } else {
                    error(result);
                }
            })
        };

        _public.dom = function () {


            var $member = $(".footer-content-text  a").eq(0),
                 $bosss = $(".footer-content-text  a").eq(1);

            $member.click(function (e) {
                if($("#btn-login").length==1){
                    jalert.timeout("您未登录","确定",null,2);
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                }else if($("#js-usernickname-vk").data("type")==1){
                    jalert.alert("您不是义工不能访问,请注销后更换账号登录","确定",null);
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                }
                common.skipUri(router.getUrl("memberJSP"));
            });
            $bosss.click(function (e) {

                if($("#btn-login").length == 1 ){
                    jalert.timeout("您未登录","确定",null,2);
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                }else if($("#js-usernickname-vk").data("type")==0){
                    jalert.alert("您不是客栈老板不能访问,请注销后更换账号登录","确定",null);
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                }
                common.skipUri(router.getUrl("bossJSP"));

            });



            function popup(str) {



                //#popup用show或者toggle之类函数 其他类别用hide来操作  因为其他hide类有的不能显示为block;
                //log-reg-box里包含登录和注册 step-0是登录 step-1是注册 step-2是手机绑定(需要禁用顶部右侧的按钮 添加disabled类)
                //back-svg-tab里的a添加disabled类可以使所有的a标签失效 处于失效 ,disabled属性在reset.css中
                var poppane = {
                    info: ["个人", "手机"],//用于记录一些信息
                    init: init,//body添加scrollhide类  显示popup 绑定点击mask关闭popup 绑定已有账号-让我登录按钮
                    show_login: show_login,//显示login版面
                    show_register: show_register,//显示register版面
                    show_report: show_report,//显示举报
                    show_callback: show_callback,//显示反馈
                    reset: reset,//重新给全部类添加hide类
                    close: close,//关闭popup 去除mask的事件函数
                    left_title: left_title,//顶部的title切换 显示左边的title
                    right_title: right_title,//
                    type: 'member'
                };




                var phone_reg = /^1\d{10}$/;
                var email_reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

                $(".js-qq").click(function(e){

                    var $this = $(this);
                    common.send("qqLink",{type:poppane.type}).done(function(result){
                        if(result && result.code ==1){
                            common.skipUri($this.attr("href"));
                        }
                    });
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                });



                if (str == "login") {
                    poppane.init().left_title().show_login();
                    //登录的一些函数去show_login
                } else if (str == "register") {
                    poppane.init().left_title().show_register();
                    //注册的一些函数绑定去show_register
                } else if (str == "report") {
                    poppane.init().left_title().show_report();
                    //注册的一些函数绑定去show_register
                } else if (str == "callback") {
                    poppane.init().left_title().show_callback();
                    //注册的一些函数绑定去show_register
                }
                function init() {
                    //隐藏body的scroll条
                    //popup使用positon:absolute;top,left,right,bottom;0;所以没有滚动条
                    $(document.body).addClass("scroll-hide");
                    //显示主体
                    $("#popup").fadeIn("fast");
                    //点击mask关闭弹窗
                    $("#mask").on("click", function () {
                        poppane.close().reset();
                    });
                    $("#popup .let-me-login").on("click", function () {
                        poppane.reset().show_login();
                    });
                    return this
                }

                function show_login() {
                    //显示登录页面
                    //去掉隐藏框
                    $("#popup .log-reg-box").removeClass("hide");
                    //bind  some listeners on the below
                    //...

                    $(".step-0").removeClass("hide");

                    //左右顶部的事件
                    $(".back-svg-tab .log-reg-box .left .step-0 a").click(function () {
                        poppane.left_title().info[0] = "个人";
                        poppane.type = 'member'
                    });
                    $(".back-svg-tab .log-reg-box .right .step-0 a").click(function () {
                        poppane.right_title().info[0] = "商家";
                        poppane.type = 'boss'
                    });

                    //回车登录
                    $("#l-password").keydown(function (e) {
                        if (e.keyCode == 13) {
                            $(".step-0 .btn-primary").click();
                        }
                    });
                    //绑定的btn-primary
                    $(".step-0").on("click", ".btn-primary,.more,.forget-password", function () {
                        var type = poppane.info[0];//第一个是登录类型 如果手机和邮箱用不同的接口 需要将下面的测试用上来
                        var username = $("#l-username").val().trim();
                        var password = $("#l-password").val().trim();
                        var $a = $(this);
                        if ($a.hasClass("more")) {
                            //前往注册
                            $(".step-0").addClass("hide").off("click");
                            poppane.show_register();
                            return;
                        } else if ($a.hasClass("forget-password")) {
                            //忘记密码
                            //??
                            window.location.href = router.getUrl("forget_pwd");
                            return false;
                        } else {
                            var op = phone_reg.test(username)? 'mobile':'email';

                            _private.login({
                                type: poppane.type,
                                option: op,
                                account: username,
                                pwd: password
                            }, function (res) {
                                if (res.code == 1) {
                                    common.skipUri(window.location.href);
                                } else {
                                    jalert.error(res.info,"确定");
                                }
                            }, function (info) {
                                $(".l-err-info,.error").show();
                                $(".error").text(info);
                            },poppane);

                        }
                    });
                };
                function show_register() {
                    //显示登录页面
                    //去掉隐藏框
                    $("#popup .log-reg-box").removeClass("hide");
                    $(".step-1").removeClass("hide");


                    //设置时间禁用再次获取
                    //左右顶部的事件
                    $(".back-svg-tab .log-reg-box .left .step-1 a").click(function () {
                        poppane.left_title().info[0] = "个人";
                        poppane.type = "member";
                    });
                    $(".back-svg-tab .log-reg-box .right .step-1 a").click(function () {
                        poppane.right_title().info[0] = "商家";
                        poppane.type = "boss";
                    });
                    $("#next-v").on("click", function () {
                        $(this).children().attr("src", "");
                    });

                    $(".step-1").on("click", ".btn-primary,.more", function () {
                        //点击注册按钮会怎么做 现在是隐藏第这一步,进入手机绑定

            if($(this).hasClass("more")){

                window.open(router.getUrl("contract"));
                return false;
            }
                        var username = $("#r-username").val().trim();
                        var password = $("#r-password").val();
                        var password2 = $("#r-password-2").val();
                        var agree = $("#r-agree").prop("checked");
                        var err = {
                            s: function (text) {
                                $(".r-err-info").show().find(".error").text("*" + text);
                            }, hide: function () {
                                $(".r-err-info").hide()
                            }
                        };

                        err.hide();
                        if (password == "") {
                            err.s("密码不能为空");
                            return false
                        } else {
                            if (!/^[A-Za-z0-9_]{6,18}$/.test(password)) {
                                err.s("密码为6至18位的任意大小写字母、数字、下划线");
                                return false
                            } else {
                                err.hide();
                            }
                            if (password != password2) {
                                err.s("两次密码不一致!");
                                return false
                            } else {
                                err.hide();
                            }
                        }
                        if (!agree) {
                            err.s("请同意《用户服务协议》");
                            return false;
                        } else {
                            err.hide();
                        }


                        if (phone_reg.test(username)) {
                            //隐藏注册第一步
                            $(".step-1").addClass("hide");
                            $(".step-1").off();
                            $(".back-svg-tab .log-reg-box .step-1 a").off();
                            $(".step-2").removeClass("hide");
                            poppane.left_title();

                            var tryagian = {
                                i: {},
                                count: 59,
                                on: function () {
                                    $(".tryAgain").text('请求中..').addClass("disabled");
                                    var self = this;
                                    _private.register({
                                        type: poppane.type,
                                        option: 'mobile',
                                        account: username
                                    }, function (result) {
                                        jalert.alert(result.info,"确定")
                                        self.i = setInterval(function () {
                                            if (tryagian.count != -1) {
                                                $(".tryAgain").text(tryagian.count-- + "秒后重新获取").addClass("disabled");
                                            } else {
                                                tryagian.off();
                                            }
                                        }, 1000)
                                    }, function (result) {

                                        jalert.error(result.info,"确定");
                                        self.off();
                                    })


                                },
                                off: function () {
                                    $(".tryAgain").removeClass("disabled").text("点击获取验证码");
                                    clearInterval(this.i);
                                    this.count = 59;
                                }
                            };


                            tryagian.on();
                            $(".tryAgain").click(function () {
                                //点击再次获取验证码后
                                //再次发送验证码
                                tryagian.on();
                            });
                            $(".step-2").on("click", ".btn-primary", function () {
                                if ($(this).hasClass("tryAgain")) {
                                    return false;
                                }
                                var verify = $("#r-verify-check").val();
                                //输入验证码后
                                _private.register({
                                    type: poppane.type,
                                    option: 'mobile',
                                    pwd: password,
                                    verid: parseInt($("#r-verify-check").val())
                                }, function (result) {
                                    $(".step-2 .info").html("验证成功!前往个人中心!!");
                                    jalert.alert(result.info,"确定")
                                    setTimeout(function () {
                                        if (poppane.type == "member") {
                                            common.skipUri(router.getUrl("memberJSP"));
                                        }else {
                                            common.skipUri(router.getUrl("bossJSP"));
                                        }
                                        poppane.reset().close();
                                        //前往个人中心
                                    }, 2000)
                                }, function (result) {
                                    $(".step-2 .info").html("<span class='error'>验证失败！" + "\n" + (result.info || '') + "</span>")
                                })
                            });
                        } else if (email_reg.test(username)) {

                            _private.register({
                                type: poppane.type,
                                option: 'email',
                                account: username,
                                pwd: password
                            }, function (result) {

                                //禁用手机验证tab
                                poppane.right_title();
                                //隐藏注册第一步
                                $(".step-1").addClass("hide");
                                $(".back-svg-tab .log-reg-box .step-1 a").off();
                                $(".step-3").removeClass("hide");
                                //设置邮箱名称和链接
                                var $email = $("#popup #email-link");
                                $email.text(username);

                                jalert.alert(result.info,"确定");
                                var hash = {
                                    'qq.com': 'http://mail.qq.com',
                                    'gmail.com': 'http://mail.google.com',
                                    'sina.com': 'http://mail.sina.com.cn',
                                    '163.com': 'http://mail.163.com',
                                    '126.com': 'http://mail.126.com',
                                    'yeah.net': 'http://www.yeah.net/',
                                    'sohu.com': 'http://mail.sohu.com/',
                                    'tom.com': 'http://mail.tom.com/',
                                    'sogou.com': 'http://mail.sogou.com/',
                                    '139.com': 'http://mail.10086.cn/',
                                    'hotmail.com': 'http://www.hotmail.com',
                                    'live.com': 'http://login.live.com/',
                                    'live.cn': 'http://login.live.cn/',
                                    'live.com.cn': 'http://login.live.com.cn',
                                    '189.com': 'http://webmail16.189.cn/webmail/',
                                    'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
                                    'yahoo.cn': 'http://mail.cn.yahoo.com/',
                                    'eyou.com': 'http://www.eyou.com/',
                                    '21cn.com': 'http://mail.21cn.com/',
                                    '188.com': 'http://www.188.com/',
                                    'foxmail.coom': 'http://www.foxmail.com'
                                };

                                var url = username.split("@")[1];

                                $("#email-link").attr("href", hash[url])

                                $(".step-3").on("click", ".btn-primary", function () {
                                    poppane.reset().close();
                                });
                                var fake_count = 4;
                                setInterval(function(){
                                    $("#js-five-count").text(fake_count--)
                                });
                                setTimeout(function () {
                                    if (poppane.type == "member") {
                                        common.skipUri(router.getUrl("memberJSP"));
                                    }else {
                                        common.skipUri(router.getUrl("bossJSP"));
                                    }
                                    poppane.reset().close();
                                    //前往个人中心
                                }, 4000)

                            }, function (result) {

                                if(result && result.code==0){
                                    jalert.error(result.info,"确定");
                                    poppane.reset().show_register();
                                }
                            });

                        } else {
                            if(/\d*/.test(username) ){
                                err.s("手机号或用户名输入错误!");
                            }else{
                                err.s("用户名或密码错误!");
                            }

                        }
                    })
                }

                function show_report() {
                    //隐藏右上的tab
                    $("#popup .back-svg .right").addClass("hide");//
                    //显示反馈box
                    //去掉隐藏框
                    $("#popup .callback-box").removeClass("hide");//
                    $("#popup .report-content").removeClass("hide");//
                    //暂无
                }
                ;
                function show_callback() {
                    //
                    $("#popup .callback-box").removeClass("hide");//
                    $("#popup .back-svg .right").addClass("hide");//
                    $("#popup .callback-content").removeClass("hide");//

                }
                ;
                function reset() {
                    $("#popup li,#popup .log-reg-box,#popup .callback-box").addClass("hide");
                    $(".step-0,.step-1,.step-2").each(function () {
                        $(this).off();
                    });
                    $(".tryAgain").off();
                    $(".back-svg-tab .log-reg-box .step-1 a").off();
                    $("#l-password").off();

                    return this
                }
                ;
                function close() {
                    $("#l-password").off();
                    $("#popup").fadeOut("fast");
                    $(document.body).removeClass("scroll-hide");
                    $("#popup input").val("");
                    $("#popup a,#popup li,#mask").off();
                    $(".l-err-info,.r-err-info").hide();
                    $('#btn-login').off();
                    $('#btn-login').click(function () {
                        popup('login')
                    });
                    $(".step-0").off();
                    $('#btn-register').off();
                    $('#btn-register').click(function () {
                        popup('register')
                    });

                    $(".js-qq").off();


                    return this
                }

                function left_title(str) {
                    $(".back-svg").removeClass("right-up").addClass("left-up");
                    return this
                }

                function right_title() {
                    $(".back-svg").removeClass("left-up").addClass("right-up");
                    return this
                }

            }

            //防止缓存造成的事件没有绑定
            var login_timer = setInterval(function(){

                if($('#btn-login').length==0){
                    console.log("waiting..")

                    if($("#js-usernickname-vk").length!=0){
                        clearInterval(login_timer);
                    }
                    ;
                } else {
                    $('#btn-login').click(function () {
                        popup('login')
                    });
                    clearInterval(login_timer);
                }
            },500);
            var register_timer = setInterval(function(){
                if($('#btn-login').length==0){

                    if($("#js-usernickname-vk").length!=0){
                        clearInterval(register_timer);
                    }
                    ;
                } else {
                    $('#btn-register').click(function () {
                        popup('register')
                    });
                    clearInterval(register_timer);
                }
            },500);


        }
        _public.dom();
    })


</script>
